package com.gitee.wsl.reflect.func.call.exception

import com.gitee.wsl.reflect.func.call.FunctionCall

/**
 * An exception thrown if a [FunctionCall] could not be executed.
 * @param call the invalid call
 * @param reason optional additional reason the call failed for
 * @param includeArguments whether to include supplied function call arguments in the error message
 */
open class InvalidFunctionCallException(
    val call: FunctionCall<*>,
    reason: String? = null,
    includeArguments: Boolean = true,
):Exception(
    "Invalid function call: ${call.function.name} ${reason?.let { "($it)" } ?: ""} ${if (includeArguments) "with arguments: ${call.arguments.joinToString { it.toString() }}" else ""}"
)